<?php

namespace App\Http\Resources\Api\Admin;

use Illuminate\Http\Resources\Json\JsonResource;

class AdminPowerResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'power_id'=>$this->power_id,
            'power' => $this->power,
            'power_name' => $this->power_name,
            'content' => $this->content,
            'module' => $this->module,
            'module_name' => $this->module_name,
            'controller' => $this->controller,
            'controller_name' => $this->controller_name,
            'action' => $this->action,
            'is_check' => $this->is_check,
            'roles' => AdminPowerRoleResource::collection($this->whenLoaded('roles')),
            'routes' => AdminPowerRouteResource::collection($this->whenLoaded('routes')),
            'route_id' => $this->route_id,
            'created_at'=>(string)$this->created_at,
            'updated_at'=>(string)$this->updated_at,
        ];
    }
}
